package com.xxl.shoppingapp.ui.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.xxl.shoppingapp.ui.home.ElectricalFragment;
import com.xxl.shoppingapp.ui.home.FoodFragment;
import com.xxl.shoppingapp.ui.home.FreshFragment;
import com.xxl.shoppingapp.ui.home.HomeFragment;
import com.xxl.shoppingapp.ui.home.GoodsFragment;

/**
 * @author xuelian.xiong 2018/4/10
 * @Package com.xxl.shoppingapp.ui.adapter
 * @Title: TabFragmentAdapter
 * @Description: (用一句话描述该文件做什么)
 * Copyright (c) 传化公路港物流有限公司版权所有
 * Create DateTime: 2018/4/10
 */
public class TabFragmentAdapter extends FragmentPagerAdapter {
    public final int COUNT = 4;
    private Context context;

    public TabFragmentAdapter(FragmentManager fm, Context context) {
        super(fm);
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        switch (position){
            case 0:
                return GoodsFragment.getInstance();
            case 1:
                return FreshFragment.getInstance();
            case 2:
                return FoodFragment.getInstance();
            case 3:
                return ElectricalFragment.getInstance();
            default:
                return GoodsFragment.getInstance();
        }

    }

    @Override
    public int getCount() {
        return COUNT;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return HomeFragment.sTitle[position];
    }
}
